package com.yuexun.beilunpatient.ui.question.adapter;

import android.os.Bundle;
import android.view.View;
import android.widget.AbsListView;
import android.widget.TextView;

import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.baselistener.ICallBackListener;
import com.yuexun.beilunpatient.ui.question.bean.PatientQuestionBean;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.Collection;

/**
 * Created by chenss on 2018/3/22 0022.
 */

public class QuestionListAdapter extends KJAdapter<PatientQuestionBean> {

    ICallBackListener backListener;

    public void setBackListener(ICallBackListener backListener) {
        this.backListener = backListener;
    }

    public QuestionListAdapter(AbsListView view, Collection<PatientQuestionBean> mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(AdapterHolder helper, PatientQuestionBean item, boolean isScrolling) {
        super.convert(helper, item, isScrolling);
    }

    @Override
    public void convert(AdapterHolder helper, PatientQuestionBean item, boolean isScrolling, final int position) {
        super.convert(helper, item, isScrolling, position);
        helper.setText(R.id.ask_time, "时间：" + item.getCreateTime());
        helper.setText(R.id.type, "类型：" + item.getType());
        helper.setText(R.id.organization, "医疗机构：" + item.getHospName());
        TextView textView = helper.getView(R.id.question_detail);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putInt("position", position);
                backListener.callback(bundle);
            }
        });
    }
}
